package com.im.partchat.http.service;

import com.im.partchat.bean.Group;
import com.im.partchat.bean.reponsed.BaseResponse;
import com.im.partchat.bean.reponsed.GroupQueryReponse;
import com.im.partchat.bean.request.GroupCreateRequest;
import com.im.partchat.bean.request.GroupDismissRequest;
import com.im.partchat.bean.request.GroupJoinRequest;
import com.im.partchat.bean.request.GroupQueryRequest;
import com.im.partchat.bean.request.GroupQuitRequest;
import com.im.partchat.bean.request.GroupRefreshRequest;
import com.im.partchat.bean.request.GroupSyncRequest;
import com.im.partchat.bean.request.RequestBean;
import com.im.partchat.http.apiManager.ApiManager;
import com.im.partchat.http.api.GroupApi;

import java.util.List;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by fzl on 2017/6/29 0029.
 * VersionCode: 1
 * Desc:
 */

public class GroupService {

    private static GroupApi groupApi  = ApiManager.getInstance().getApi(GroupApi.class);

    public static Observable<BaseResponse<List<Group>>> getGroupList(RequestBean<GroupSyncRequest> requestRequestBean) {
        return groupApi.groupList(requestRequestBean)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public static Observable<BaseResponse<String>> groupCreate(RequestBean<GroupCreateRequest> requestRequestBean) {
        return groupApi.groupCreate(requestRequestBean)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public static Observable<BaseResponse<String>> groupJoin(RequestBean<GroupJoinRequest> requestRequestBean) {
        return groupApi.groupJoin(requestRequestBean)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }

    public static Observable<BaseResponse<String>> groupQuit(RequestBean<GroupQuitRequest> requestRequestBean) {
        return groupApi.groupQuit(requestRequestBean)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public static Observable<BaseResponse<String>> groupDismiss(RequestBean<GroupDismissRequest> requestRequestBean) {
        return groupApi.groupDismiss(requestRequestBean)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public static Observable<BaseResponse<String>> groupRefresh(RequestBean<GroupRefreshRequest> requestRequestBean) {
        return groupApi.groupRefresh(requestRequestBean)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public static Observable<BaseResponse<List<GroupQueryReponse>>> groupQuery(RequestBean<GroupQueryRequest> requestRequestBean) {
        return groupApi.groupQuery(requestRequestBean)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }



}
